/*
 * CodePress regular expressions for Python syntax highlighting
 * by Phil Christensen (http://bubblehouse.org)
 */

var reserved_words = ['and', 'del', 'from', 'not', 'while', 'as', 'elif',
					  'global', 'or', 'with', 'assert', 'else', 'if', 'pass',
					  'yield', 'break', 'except', 'import', 'print', 'class',
					  'exec', 'in', 'raise', 'continue', 'finally', 'is',
					  'return', 'def', 'for', 'lambda', 'try'];
var reserved_words_regexp = new RegExp('\\b(' + reserved_words.join('|') + ')\\b', 'g');

var builtin_functions = ['__import__', 'abs', 'apply', 'basestring', 'bool', 'buffer', 'callable', 'chr', 'classmethod',
						 'cmp', 'coerce', 'compile', 'complex', 'copyright', 'credits', 'delattr', 'dict', 'dir', 'divmod',
						 'enumerate', 'eval', 'execfile', 'exit', 'file', 'filter', 'float', 'frozenset', 'getattr', 'globals',
						 'hasattr', 'hash', 'help', 'hex', 'id', 'input', 'int', 'intern', 'isinstance', 'issubclass',
						 'iter', 'len', 'license', 'list', 'locals', 'long', 'map', 'max', 'min', 'object', 'oct',
						 'open', 'ord', 'pow', 'property', 'quit', 'range', 'raw_input', 'reduce', 'reload', 'repr',
						 'reversed', 'round', 'set', 'setattr', 'slice', 'sorted', 'staticmethod', 'str', 'sum',
						 'super', 'tuple', 'type', 'unichr', 'unicode', 'vars', 'xrange', 'zip'];
var builtin_functions_regexp = new RegExp('\\b(' + builtin_functions.join('|') + ')\\b', 'g');

var builtin_exceptions = ['ArithmeticError', 'AssertionError', 'AttributeError', 'DeprecationWarning',
						  'EOFError', 'EnvironmentError', 'Exception', 'FloatingPointError', 'FutureWarning',
						  'IOError', 'ImportError', 'IndentationError', 'IndexError', 'KeyError', 'KeyboardInterrupt',
						  'LookupError', 'MemoryError', 'NameError', 'NotImplementedError', 'OSError', 
						  'OverflowError', 'OverflowWarning', 'PendingDeprecationWarning', 'ReferenceError',
						  'RuntimeError', 'RuntimeWarning', 'StandardError', 'StopIteration', 'SyntaxError',
						  'SyntaxWarning', 'SystemError', 'SystemExit', 'TabError', 'TypeError', 'UnboundLocalError',
						  'UnicodeDecodeError', 'UnicodeEncodeError', 'UnicodeError', 'UnicodeTranslateError',
						  'UserWarning', 'ValueError', 'Warning', 'ZeroDivisionError'];
var builtin_exceptions_regexp = new RegExp('\\b(' + builtin_exceptions.join('|') + ')\\b', 'g');

var builtin_objects = ['self', 'True', 'False', 'Ellipsis', 'None', 'NotImplemented', '__debug__', '__name__', '__doc__'];
var builtin_objects_regexp = new RegExp('\\b(' + builtin_objects.join('|') + ')\\b', 'g');

var innerspace_functions = ['get_dobj', 'get_dobj_str', 'has_dobj', 'has_dobj_str', 'get_pobj', 'get_pobj_str',
							'has_pobj', 'has_pobj_str', 'get_global', 'new_entity', 'sudo', 'count_names'];
var innerspace_functions_regexp = new RegExp('\\b(' + innerspace_functions.join('|') + ')\\b', 'g');

var innerspace_objects = ['system', 'caller', 'here', 'this'];
var innerspace_objects_regexp = new RegExp('\\b(' + innerspace_objects.join('|') + ')\\b', 'g');

var innerspace_methods = ['get_id', 'get_name', 'set_name', 'has_child', 'has_parent', 'get_children', 'get_parent',
						  'set_parent', 'get_contents', 'get_location', 'set_location', 'owns', 'get_owner', 'set_owner',
						  'contains', 'find', 'set_connection', 'get_observers', 'get_observations', 'get_details',
						  'get_details_unicode', 'set_observing', 'get_observing', 'observe', 'notify', 'write',
						  'has_verb', 'has_callable_verb', 'call_verb', 'get_verbs', 'get_verb_names', 'set_verb_names',
						  'add_verb', 'remove_verb', 'has_property', 'get_properties', 'has_readable_property',
						  'add_property', 'set_property', 'get_property', 'remove_property', 'get_ancestor_with',
						  'set_player', 'is_player', 'is_connected_player', 'set_programmer', 'is_programmer',
						  'set_wizard', 'is_wizard'];
var innerspace_methods_regexp = new RegExp('\\b(\\w+)\\.(' + innerspace_methods.join('|') + ')\\b', 'g');

syntax = [ // Python
	/((\'|\"){3})(.*?)((\'|\"){3})/mg,'<s>$1$3$4</s>', // strings triple quotes
	/\"(.*?)(\"|<br>|<\/P>)/g,'<s>"$1$2</s>', // strings double quote
	/\'(.*?)(\'|<br>|<\/P>)/g,'<s>\'$1$2</s>', // strings single quote

	reserved_words_regexp,'<b>$1</b>',

	builtin_exceptions_regexp,'<u>$1</u>',
	builtin_objects_regexp,'<a>$1</a>',
	builtin_functions_regexp,'<em>$1</em>',
	
	innerspace_methods_regexp,'$1.<u class="innerspace">$2</u>',
	innerspace_objects_regexp,'<a class="innerspace">$1</a>',
	innerspace_functions_regexp,'<em class="innerspace">$1</em>',
	
	/#(.*?)(<br>|<\/P>)/g,'<i>#$1</i>$2', // comments
];

CodePress.initialize();

